package org.example.reactive.demo1.handler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.server.HandlerFunction;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

/**
 * @author Gong.Yang
 */
@Slf4j
@Component
public class ScopeTestHandler {
    public Mono<ServerResponse> print(ServerRequest request, String s) {
        log.info("【{}】", s);
        return ServerResponse.ok().build();
    }

    public Mono<ServerResponse> getFilterFunction(ServerRequest request, HandlerFunction<ServerResponse> next, String logContent) {
        log.info("【{}】before", logContent);
        return next.handle(request).doOnTerminate(() -> {
            log.info("【{}】after", logContent);
        });
    }
}
